import {request} from '@/utils/request.js'
import {appConfig} from '@/config/config.js'

// 查询商品列表
export function getGoodsList(params) {
	params.orderByColumn = 'create_time'
	params.isAsc = 'desc'
	return request.get(appConfig.WEB_API + '/goods/list', params)
}

// 查询我的商品列表
export function getMyGoodsList(params) {
	return request.get(appConfig.WEB_API + '/goods/myList', params)
}

// 查询商品详细信息
export function getGoodsInfo(goodsId) {
	return request.get(appConfig.WEB_API + '/goods/' + goodsId)
}

// 获取商品所属用户
export function getUserInfo(goodsId) {
	return request.get(appConfig.WEB_API + '/goods/user/' + goodsId)
}

// 发布商品
export function publish(params) {
	return request.post(appConfig.WEB_API + '/goods/publish', params)
}

// 下架商品
export function soldOutByGoodsId(goodsId) {
	return request.put(appConfig.WEB_API + '/goods/soldOut/' + goodsId)
}

// 上架商品
export function putawayByGoodsId(goodsId) {
	return request.put(appConfig.WEB_API + '/goods/putaway/' + goodsId)
}

// 删除商品
export function deleteByGoodsId(goodsId) {
	return request.delete(appConfig.WEB_API + '/goods/delete/' + goodsId)
}

